package com.ucampus.dao;

import com.ucampus.dao.sql.ShopSql;
import com.ucampus.entity.Shop;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

public interface ShopDao {
    @Select("select * from shop")
    List<Shop> getAll();

    @Select("select * from shop where name like CONCAT('%',#{name},'%')")
    List<Shop> getByName(String name);

    @Insert("insert into shop(name,location,message) values(#{name},#{location},#{message})")
    int add(String name, String location, String message);

    @UpdateProvider(type = ShopSql.class,method = "update")
    int update(int id,String name, String location, String message);

    @Delete("<script>" +
            "delete from shop where id in" +
            "<foreach collection='list' item='id' open='(' close=')' separator=','>#{id}</foreach>" +
            "</script>")
    int delete(List<Integer> list);
}
